package com.liyujie.dyeingmachine.utils;

import android.view.Gravity;

import com.blankj.utilcode.util.ColorUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.liyujie.dyeingmachine.BaseApplication;
import com.liyujie.dyeingmachine.R;
import com.liyujie.dyeingmachine.common.Constants;
import com.raizlabs.android.dbflow.config.FlowConfig;
import com.raizlabs.android.dbflow.config.FlowLog;
import com.raizlabs.android.dbflow.config.FlowManager;

public class InitializeUtils {


    /**
     * Toast设置统一样式
     */
    private static ToastUtils defaultMaker;

    public static ToastUtils getDefaultMaker() {
        return defaultMaker;
    }

    public static void initDefaultMaker() {
        defaultMaker = ToastUtils.getDefaultMaker();
        defaultMaker.setBgColor(ColorUtils.getColor(R.color.purple_200));
        defaultMaker.setGravity(Gravity.CENTER, 0, 0);
        defaultMaker.setTextColor(ColorUtils.getColor(R.color.color_FFFFFF));
        defaultMaker.setTextSize(36);
    }


    /**
     * 日志相关
     */
    public static void initializeLogUtils() {
        LogUtils.Config config = LogUtils.getConfig();
        //设置 log 总开关
        config.setLogSwitch(true);
        //设置 log 文件开关
        config.setLog2FileSwitch(true);
        //设置 log 可保留天数
        config.setSaveDays(5);
        // 设置 log 文件存储目录
        config.setDir(Constants.LogPath);
    }


    /**
     * 初始化DBFlow
     */
    public static void initializeDBFlow(BaseApplication mBaseApplication) {
        //初始化DBFlow
        FlowManager.init(new FlowConfig.Builder(mBaseApplication).build());
        //设置日志显示
        FlowLog.setMinimumLoggingLevel(FlowLog.Level.D);
    }


    /**
     * 串口初始化
     */
    public static void initGorge() {

    }

}
